package com.futureCloudMOM.controller.core.web.produce;

import com.futureCloudMOM.common.annotation.Log;
import com.futureCloudMOM.common.core.domain.AjaxResult;
import com.futureCloudMOM.common.core.page.TableDataInfo;
import com.futureCloudMOM.controller.core.controller.BaseApiController;
import com.futureCloudMOM.core.domain.ProduceTaskBill;
import com.futureCloudMOM.core.service.ProduceTaskBillMaterialService;
import com.futureCloudMOM.core.service.ProduceTaskBillRoutingMaterialService;
import com.futureCloudMOM.core.service.ProduceTaskBillRoutingProcessService;
import com.futureCloudMOM.core.service.ProduceTaskBillService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 文件名 ProduceTaskBillController
 *
 * @since 2023/6/6 16:05
 */
@Api(tags = "生产订单")
@RestController
@RequestMapping("produce/task_bill")
public class ProduceTaskBillController extends BaseApiController<ProduceTaskBill, ProduceTaskBill, ProduceTaskBillService> {

    public ProduceTaskBillController(ProduceTaskBillService service) {
        super(service);
    }

    //@Autowired
    //private ProduceTaskBillMaterialService produceTaskBillMaterialService;
    //
    //@Log(title = "根据生产订单ID查询用料列表")
    //@ApiOperation("根据生产订单ID查询用料列表")
    //@GetMapping("{id}/materials")
    //public TableDataInfo materials(@PathVariable("id") Long id) {
    //    startPage();
    //    return getDataTable(produceTaskBillMaterialService.selectListByBillId(id));
    //}

    @Log(title = "生产订单审核")
    @ApiOperation("生产订单审核")
    @GetMapping("approve/{id}")
    public AjaxResult approve(@PathVariable("id") Long id) {
        service.approve(id);
        return success();
    }

    @Log(title = "生产订单反审核")
    @ApiOperation("生产订单反审核")
    @GetMapping("deApprove/{id}")
    public AjaxResult deApprove(@PathVariable("id") Long id) {
        service.deApprove(id);
        return success();
    }

    @Log(title = "生产订单下达")
    @ApiOperation("生产订单下达")
    @GetMapping("release/{id}")
    public AjaxResult release(@PathVariable("id") Long id) {
        service.release(id);
        return success();
    }

    @Log(title = "生产订单反下达")
    @ApiOperation("生产订单反下达")
    @GetMapping("withdrawalOfRelease/{id}")
    public AjaxResult withdrawalOfRelease(@PathVariable("id") Long id) {
        service.withdrawalOfRelease(id);
        return success();
    }

    @Log(title = "生产订单关闭")
    @ApiOperation(value = "生产订单关闭")
    @GetMapping("produceClose/{id}")
    public AjaxResult produceClose(@PathVariable("id") Long id){
        service.produceClose(id);
        return success();
    }

    @Log(title = "生产订单反关闭")
    @ApiOperation(value = "生产订单反关闭")
    @GetMapping("produceUnclose/{id}")
    public AjaxResult produceUnclose(@PathVariable("id") Long id){
        service.produceUnclose(id);
        return success();
    }

    @Log(title = "根据生产订单ID查询订单工艺工序列表")
    @ApiOperation("根据生产订单ID查询订单工艺工序列表")
    @GetMapping("processes/{id}")
    public TableDataInfo processes(@PathVariable("id") Long id) {
        startPage();
        return getDataTable(service.getProcessListByTaskBillId(id));
    }

    @Log(title = "根据计划ID查询计划明细")
    @ApiOperation(value = "根据计划ID查询计划明细")
    @GetMapping("getProduceSub/{id}")
    public TableDataInfo getProduceSub(@PathVariable("id") Long id){
        startPage();
        return getDataTable(service.getTaskBillSubListByTaskBillId(id));
    }

}
